package com.tencent.trtc.apiexample;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import static com.tencent.trtc.apiexample.LoginActivity.PATH;
import static com.tencent.trtc.apiexample.LoginActivity.USERNAME;

public class CreateRoomActivity extends AppCompatActivity {
    private EditText met_create_room_name;
    private EditText met_create_room_pwd;
    private Button mbtn_create_room;

    private String roomname = "";
    private String roompwd = "";
    private String inf = "";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_create_room);

        met_create_room_name=findViewById(R.id.et_create_room_name);
        met_create_room_pwd=findViewById(R.id.et_create_room_pwd);
        mbtn_create_room=findViewById(R.id.btn_create_room);

        mbtn_create_room.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                roomname=met_create_room_name.getText().toString();
                roompwd=met_create_room_pwd.getText().toString();
                new Thread(new MyThread()).start();
            }
        });
    }
    class MyThread implements Runnable {

        @Override
        public void run() {
            String path = PATH + "/roomcreate?RoomName=" + roomname + "&Rpassword=" + roompwd +"&creater="+USERNAME;
            inf = WebServiceGet.executeHttpGet(path);
            Intent intent = new Intent(CreateRoomActivity.this,NavActivity.class);
            intent.putExtra("createinf",inf);
            startActivity(intent);
        }
    }
}